﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MyDMS.BusinessLayer;

public partial class Compose : PageBaseClass
{
    MailMessageFactory mMsgFactory;

    protected void Page_Load(object sender, EventArgs e)
    {
        txtSentDate.Text = DateTime.Now.ToString("MMM d, yyyy");
    }

    protected void btnSave_Click(object sender, EventArgs e)
    {
        MailMessage mMsg = new MailMessage();
        mMsg.Message_Subject = txtDocName.Text;
        mMsg.Message_Body = txtBody.Text;
        mMsg.Sent_Date = DateTime.Parse(txtSentDate.Text);

        mMsg.Owner = _author.user_Code;
        mMsg.Office_Code = _author.office_Code;

        mMsgFactory = new MailMessageFactory();
        if (mMsgFactory.Insert(mMsg))
        {
            //List<UserFolder> uFolders = new UserFolderFactory().GetAllBy(UserFolder.UserFolderFields.User_Code, _author.user_Code);
            //for (int i = 0; i < uFolders.Count; i++)
            //{
            //    if (uFolders[i].Is_Default)
            //    {
            //        UserDocumentInFolder uDocInFolder = new UserDocumentInFolder();
            //        uDocInFolder.Document_Code = mMsg.Document_Code;
            //        uDocInFolder.Folder_Code = uFolders[i].Folder_Code;

            //        new UserDocumentInFolderFactory().Insert(uDocInFolder);
            //        break;
            //    }
            //}
            lblMessage.Text = "Saved Successfully";
        }
        else
        {
            lblMessage.Text = "Error!";
        }
        lblMessage.Visible = true;
    }
}
